<template>
	<view class="tabbar-main">
		<view style="height: 53px;"></view>
		<view class="cu-bar tabbar  bg-white">
			<view class="action" :class="{'text-green':page == 0}" @click="go(0)">
				<view class="cuIcon-homefill"></view> 首页
			</view>
			<view class="action add-action" :class="{'text-green':page == 1}" @click="go(1)">
				<button class="cu-btn cuIcon-add bg-green shadow"></button>
				发布
			</view>
			<view class="action" :class="{'text-green':page == 2}" @click="go(2)">
				<view class="cuIcon-my">
					<view class="cu-tag badge">{{num}}</view>
				</view>
				我的
			</view>
		</view>
	</view>
	</view>
</template>
<script>
	import {
		mapState
	} from "vuex"
	export default {
		data() {
			return {
				// this.num = this.$store.state.msg.length + this.$store.state.checknum.result.affectedDocs
			};
		},
		computed: {
			...mapState(['page', 'num'])
		},
		methods: {
			go(index) {
				this.$store.commit('changePage', index)
				var url
				switch (index) {
					case 0:
						url = "../../pages/index/index"
						break;
					case 1:
						url = "../../pages/fabu/fabu"
						break;
					default:
						url = "../../pages/my/my"
						break;
				}
				uni.reLaunch({
					url
				})
			}
		}
	}
</script>
<style lang="scss">
	.tabbar-main {
		width: 100%;

		.tabbar {
			width: 100%;
			bottom: 0;
			position: fixed;
		}
	}
</style>
